﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Media;
using System.Windows.Media.Effects;
using static System.Net.Mime.MediaTypeNames;

namespace Boting.Demo.TextStyle
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private Geometry CreateTextGeometry()
        {
            // Create the formatted text based on the properties set.
            FormattedText formattedText = new FormattedText(
                "666",
                CultureInfo.GetCultureInfo("en-us"),
                FlowDirection.LeftToRight,
                new Typeface("Consolas"),
                28,
                System.Windows.Media.Brushes.Black,// This brush does not matter since we use the geometry of the text.
                100) ;
            // Build the geometry object that represents the text.

            return formattedText.BuildGeometry(new Point(0, 0));
        }


        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);
            var geometry = CreateTextGeometry();
            // Draw the outline based on the properties that are set.
            drawingContext.DrawGeometry(Brushes.Orange, new Pen(Brushes.Red, 2), geometry);
        }
    }
}
